package leetcode.code0387;

public class Solution {

	public int firstUniqChar(String s) {
		Integer[] hash = new Integer[26];
		char[] cs = s.toCharArray();
		for (int i = 0; i < cs.length; i++) {
			int cur = cs[i] - 'a';
			if (hash[cur] == null) {
				hash[cur] = i;
			} else if (hash[cur] != -1) {
				hash[cur] = -1;
			}
		}
		int ans = Integer.MAX_VALUE;
		for (Integer element : hash) {
			if (element != null && element != -1) {
				ans = Math.min(ans, element);
			}
		}
		return ans == Integer.MAX_VALUE ? -1 : ans;
	}
}
